

# from jquery.博客 import *
from django.http import HttpResponse
from pathlib import Path
import os
from django.shortcuts import render

BASE_DIR = Path(__file__).resolve().parent.parent.parent

# os.path.join 该方法拼接路径,可以避免window下路径问题
ls = os.path.join(BASE_DIR, "index.html")

# print(f"{BASE_DIR}\jquery\博客\index.html")

def index_view(res):
    if res.method == 'GET':
        return render(res, "index.html", {'baba':'阿巴阿巴'})
    
def index1_view(rew):
    ls = '<h1>阿巴阿巴</h1>'
    return HttpResponse(ls)

def logion(res):
    return render(res, "login.html")

def mycal(res):
    if res.method == 'GET':
        return render(res, "cal.html")
    elif res.method == 'POST':
        x = int(res.POST.get('x', '没有填写值!'))
        y = int(res.POST.get('y', '没有填写值!'))
        op = res.POST.get('op')
        if op == 'add':
            jie = x + y
        elif op == 'sub':
            jie = x - y
        elif op == 'chen':
            jie = x * y
        elif op == 'chu':
            jie = x / y
        return render(res, "cal.html", locals()) # local函数返回当前局部所有变量